package com.home.Entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.swing.ImageIcon;

import org.hibernate.annotations.Proxy;

import com.home.Common.Common;
import com.home.Common.Resources_Truc;

@Entity
@Proxy(lazy=false)
@Table(name="MON")
public class Mon {
	
	@Id
	@Column(name="MON_MASO")
	private long maSo;
	@Column(name="MON_TEN")
	private String ten;
	@Column(name="MON_HINHANH")
	private String hinhAnh;
	@Column(name="MON_MOTA")
	private String moTa;
	@Column(name="MON_TINHTRANG")
	private boolean tinhTrang;
	@Column(name="MON_GIAGOC")
	private float giaGoc;
	@Column(name="MON_GIABAN")
	private float giaBan;
	@ManyToOne
	@JoinColumn(name="MON_DVT")
	private DVT dvt;
	@ManyToOne
	@JoinColumn(name="MON_NHOMMON")
	private NhomMon nhomMon;
	public long getMaSo() {
		return maSo;
	}
	public void setMaSo(long maSo) {
		this.maSo = maSo;
	}
	public String getTen() {
		return ten;
	}
	public void setTen(String ten) {
		this.ten = ten;
	}
	public String getHinhAnh() {
		return hinhAnh;
	}
	public void setHinhAnh(String hinhAnh) {
		this.hinhAnh = hinhAnh;
	}
	public String getMoTa() {
		return moTa;
	}
	public void setMoTa(String moTa) {
		this.moTa = moTa;
	}
	public float getGiaGoc() {
		return giaGoc;
	}
	public void setGiaGoc(float giaGoc) {
		this.giaGoc = giaGoc;
	}
	public float getGiaBan() {
		return giaBan;
	}
	public void setGiaBan(float giaBan) {
		this.giaBan = giaBan;
	}
	public DVT getDvt() {
		return dvt;
	}
	public void setDvt(DVT dvt) {
		this.dvt = dvt;
	}
	public NhomMon getNhomMon() {
		return nhomMon;
	}
	public void setNhomMon(NhomMon nhomMon) {
		this.nhomMon = nhomMon;
	}
	
	public ImageIcon getImageIcon()
	{		
		try{
			if(this.hinhAnh != null){
				ImageIcon img = new  ImageIcon(this.hinhAnh);
				return img;
			}else
				return Common.getImageIcon(Resources_Truc.MON_IMAGE);
		}catch(Exception e){
			return Common.getImageIcon(Resources_Truc.MON_IMAGE);
		}
	}
	public boolean isTinhTrang() {
		return tinhTrang;
	}
	public void setTinhTrang(boolean tinhTrang) {
		this.tinhTrang = tinhTrang;
	}
	
}
